package logic

import (
	"context"
	"errors"
	"month2/C/rpc_C/model/mysql"

	"month2/C/rpc_C/internal/svc"
	"month2/C/rpc_C/order"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateOrderStatusLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateOrderStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateOrderStatusLogic {
	return &UpdateOrderStatusLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateOrderStatusLogic) UpdateOrderStatus(in *order.UpdateOrderStatusRequest) (*order.UpdateOrderStatusResponse, error) {
	o := mysql.Order1{}
	err := o.Update(in.OrderSn, in.Status)
	if err != nil {
		logx.Error("失败")
		return nil, errors.New("失败")
	}
	return &order.UpdateOrderStatusResponse{
		Success: true,
	}, nil
}
